<?php
namespace app\house\model;
use app\BaseModel;
use think\facade\Db;



class AdminApartment extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_house_huxing';

    /**
     * @param $dis
     * @return array
     * @throws \think\exception\DbException
     * 房产户型列表
     */
    public function apartmentList($dis){
        $data = $this->where($dis)->order('sort desc')->select()->toArray();
        return $data;
    }


    /**
     * @param $dis
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * 获取所有户型
     *
     */
    public function apartmentSelect($dis){
        $data = $this->where($dis)->order('sort desc')->select()->toArray();
        return $data;
    }

    /**
     * @param $data
     * @return int|string
     * 添加户型价格
     */
    public function apartmentAdd($data){
        $data['create_time'] = time();
        $data['update_time'] = time();
        $res = $this->insert($data);
        return $res;
    }


    /**
     * @param $dis
     * @param $data
     * @return AdminCate
     * 编辑户型价格
     */
    public function apartmentUpdate($dis,$data){
        $data['update_time'] = time();
        $res = $this->where($dis)->update($data);
        return $res;

    }


    /**
     * @param $dis
     * 房产户型详情
     */
    public function apartmentInfo($dis){
        $data = $this->where($dis)->find();
        return !empty($data)?$data->toArray():$data;
    }


    /**
     * @param $dis
     * @return bool
     * @throws \Exception
     * 删除户型价格
     */
    public function apartmentDel($dis){
        $res = $this->where($dis)->delete();
        return $res;

    }



}